package net.neptech.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import net.neptech.model.sys.Dept;
import net.neptech.model.sys.Menu;
import net.neptech.utils.StringUtils;
import net.neptech.vm.constant.UserConstants;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: liyuxiang
 * @Date: 2025/8/15 14:20
 * @Description: 树结构实体类，主要用于前端select菜单树，部门树
 */

public class TreeSelectVo implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 节点ID
     */
    private Long id;

    /**
     * 节点名称
     */
    private String label;

    /**
     * 节点禁用
     */
    private boolean disabled = false;

    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelectVo> children;

    public TreeSelectVo() {

    }

    public TreeSelectVo(Dept dept) {
        this.id = dept.getDeptId();
        this.label = dept.getDeptName();
//        this.disabled = StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus());
        this.disabled = false;
        this.children = dept.getChildren().stream().map(TreeSelectVo::new).collect(Collectors.toList());
    }

    public TreeSelectVo(Menu menu) {
        this.id = menu.getMenuId();
        this.label = menu.getMenuName();
        this.children = menu.getChildren().stream().map(TreeSelectVo::new).collect(Collectors.toList());
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public boolean isDisabled() {
        return disabled;
    }

    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

    public List<TreeSelectVo> getChildren() {
        return children;
    }

    public void setChildren(List<TreeSelectVo> children) {
        this.children = children;
    }
}